package com.zmn.oms.common.enums;

import com.zmn.common.dictionary.DictModel;

import java.util.ArrayList;
import java.util.List;

/**
 * 类描述：对接渠道的接口标识
 *
 * @author lhl
 * @date 2020/11/26 21:23
 */
public enum ChannelFacade {
    OPEN_API(100, "OPEN-API", true, null),
    JINGDOND_SERVICE_PLUS(101, "京东服务+", false, null),
    TONGCHENG_58(102, "58同城", false, null),
    DAOJIA_58(103, "58到家", false, null),
    DAOWEI(104, "到位", false, null),
    PINDUODUO(105, "拼多多", false, "pinDuoDuoFacadeService"),

    UNKNOW(-1, "未知", false, null);

    /**
     * 通过FacadeID获取对应的枚举
     * @param facadeId
     * @return
     */
    public static ChannelFacade getByFacadeId(int facadeId) {
        switch (facadeId) {
            case 101:
                return JINGDOND_SERVICE_PLUS;
            case 102:
                return TONGCHENG_58;
            case 103:
                return DAOJIA_58;
            case 104:
                return DAOWEI;
            case 105:
                return PINDUODUO;
            default:
                return UNKNOW;
        }
    }

    /**
     * 获取渠道门户列表
     * @return
     */
    public static List<DictModel> getChannelFacadeList() {
        List<DictModel> items = new ArrayList<>(8);
        items.add(new DictModel(OPEN_API.getId(), OPEN_API.getName()));
        items.add(new DictModel(JINGDOND_SERVICE_PLUS.getId(), JINGDOND_SERVICE_PLUS.getName()));
        items.add(new DictModel(TONGCHENG_58.getId(), TONGCHENG_58.getName()));
        items.add(new DictModel(DAOJIA_58.getId(), DAOJIA_58.getName()));
        items.add(new DictModel(DAOWEI.getId(), DAOWEI.getName()));
        items.add(new DictModel(PINDUODUO.getId(), PINDUODUO.getName()));
        return items;
    }

    /* 成员变量 */
    private int id;
    private String name;
    private boolean requireChannelId;
    /**
     * 对应使用的 FacadeMessageEventHandler 实例在Spring容器中的名称
     */
    private String facadeMessageEventHandler;

    /* 构造器 */
    ChannelFacade(int id, String name, boolean requireChannelId, String facadeMessageEventHandler) {
        this.id = id;
        this.name = name;
        this.requireChannelId = requireChannelId;
        this.facadeMessageEventHandler = facadeMessageEventHandler;
    }

    /* 公共方法 */
    public int getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public String getFacadeMessageEventHandler() {
        return facadeMessageEventHandler;
    }

    public boolean isRequireChannelId() {
        return requireChannelId;
    }
}
